<!--项目结项-->
<template>
  <div>
    <div class="top-title">项目结项</div>
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-row>
        <el-col :span="6">
          <el-form-item label="经办人：" prop="responsiblePerson">
            <el-input v-model="ruleForm.responsiblePerson"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="经办日期：" prop="date">
            <el-input v-model="ruleForm.date"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="经办部门：" prop="depart">
            <el-input v-model="ruleForm.depart"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="№：" prop="number">
            <el-input v-model="ruleForm.number"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="经办单位：" prop="unit">
            <el-input v-model="ruleForm.unit"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <div class="tab-part">
        <span class="part-line"></span>
        <span class="part-title">基本信息</span>
      </div>
      <el-row>
        <el-col :span="12">
          <el-form-item label="项目名称：" prop="entryName">
            <el-input v-model="ruleForm.entryName"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="项目负责人：" prop="responsiblePerson">
            <el-input v-model="ruleForm.responsiblePerson"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="结项日期：" prop="date">
            <el-input v-model="ruleForm.date"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item label="开始日期：" prop="planStartTime">
            <el-input v-model="ruleForm.planStartTime"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="结束日期：" prop="planEndTime">
            <el-input v-model="ruleForm.planEndTime"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="工期：" prop="duration">
            <el-input v-model="ruleForm.duration" style="width: 60px;"></el-input>
            天
            <el-button type="primary" plain size="mini" round style="margin-left: 5px" @click="clickEvent">成本分析</el-button>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="项目编号：" prop="entryNumber">
            <el-input v-model="ruleForm.entryNumber"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="预期成果：" prop="expectedResults">
            <el-input v-model="ruleForm.expectedResults"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="取得成果：" prop="achieveResults">
            <el-input v-model="ruleForm.achieveResults"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="项目总结：" prop="summary">
            <el-input v-model="ruleForm.summary"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <div class="tab-part">
        <span class="part-line"></span>
        <span class="part-title">审批意见</span>
      </div>
      <el-input
        type="textarea"
        :rows="2"
        placeholder="请输入审批意见"
        v-model="ruleForm.approval"
      >
      </el-input>
      <div v-if="ModalType=='add'" style="display: flex;justify-content: flex-end;margin-top: 16px">
        <el-button @click="send('ruleForm')">发送</el-button>
        <el-button type="primary" @click="save('ruleForm')">保存待发</el-button>
      </div>
    </el-form>
    <el-dialog
      width="60%"
      :visible.sync="dialogVisible"
      append-to-body
    >
      <img :src="require(`../images/cbfx.png`)" alt="" class="page-img"/>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'projectClosurePage',
  data() {
    return {
      ruleForm: {
        responsiblePerson: '',
        date: '',
        depart: '',
        number: '',
        unit: '',
        entryName: '',
        planStartTime: '',
        planEndTime: '',
        duration: '',
        entryNumber: '',
        expectedResults: '',
        achieveResults: '',
        summary: '',
        approval: ''
      },
      rules: {
        // responsiblePerson: [
        //   { required: true, message: '请输入合同名称', trigger: 'blur' },
        //   { max: 20, message: '长度最大20个字符', trigger: 'blur' }
        // ],
        // date: [
        //   { required: true, message: '请输入合同编号', trigger: 'blur' }
        // ]
      },
      dialogVisible:false
    }
  },
  props: {
    row: {
      type: Object,
      default: () => {
      }
    },
    //关闭弹窗
    closeModal: {
      type: Function,
      default: null
    },
    ModalType: {
      type: String,
      default: ''
    }
  },
  watch: {
    row(n) {
      if (Object.keys(n).length !== 0) {
        this.ruleForm = Object.assign({}, n)
      }
    }
  },
  mounted() {
    if (Object.keys(this.row).length !== 0) {
      this.ruleForm = Object.assign({}, this.row)
    }
  },
  methods: {
    //发送
    send(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$message.success('发送成功！')
          this.closeModal()
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    //保存
    save(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$message.success('保存成功！')
          this.closeModal()
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    clickEvent(){
      this.dialogVisible=true
    }
  }
}
</script>

<style scoped lang="scss">
.top-title {
  font-size: 24px;
  font-weight: bold;
  color: #ffffff;
  background: #1ab394;
  padding: 16px;
  align-items: center;
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.tab-part {
  display: flex;
  align-items: center;
  border-bottom: 2px solid #e7eff3;
  padding-bottom: 10px;
  margin-bottom: 16px;

  .part-line {
    display: inline-block;
    width: 4px;
    height: 16px;
    background-color: #1ab394;
    float: left;
    margin-top: 2px;
    margin-right: 10px;
  }

  .part-title {
    font-weight: bold;
  }
}
.el-button--mini.is-round {
  padding: 6px 4px !important;
}
.page-img{
  width: 100%;
}
</style>
